﻿using System;
using System.Collections.Generic;

namespace HangerSupport
{
	public struct HSMatInfo
	{
		public HSMatInfo(HSMatInfo curDef)
		{
			this.m_lstTypeInfo = new List<string>();
			this.m_strName = curDef.m_strName;
			this.m_strCode = curDef.m_strCode;
			this.m_strMatLibName = curDef.m_strMatLibName;
			this.m_strMatLibCode = curDef.m_strMatLibCode;
			this.m_dWide = curDef.m_dWide;
			this.m_dHigh = curDef.m_dHigh;
			this.m_dThick = curDef.m_dThick;
			this.m_dThickMid = curDef.m_dThickMid;
			this.m_strErrorInfo = curDef.m_strErrorInfo;
			this.m_kSecType = curDef.m_kSecType;
			foreach (string item in curDef.m_lstTypeInfo)
			{
				this.m_lstTypeInfo.Add(item);
			}
		}

		public bool IsDefineValid()
		{
			double num = 5000.0;
			switch (this.m_strCode[0])
			{
			case 'A':
			{
				bool flag = this.m_dWide < 1.0 || this.m_dWide > num;
				if (flag)
				{
					this.m_strErrorInfo = "圆钢直径有误";
					return false;
				}
				bool flag2 = this.m_dHigh < 1.0 || this.m_dHigh > num;
				if (flag2)
				{
					this.m_strErrorInfo = "圆钢直径有误";
					return false;
				}
				bool flag3 = this.m_dThick <= 0.0 || this.m_dThick > num;
				if (flag3)
				{
					this.m_strErrorInfo = "厚度有误";
					return false;
				}
				this.m_dHigh = this.m_dWide;
				break;
			}
			case 'B':
			{
				bool flag4 = this.m_dWide < 1.0 || this.m_dWide > num;
				if (flag4)
				{
					this.m_strErrorInfo = "角钢宽度有误";
					return false;
				}
				bool flag5 = this.m_dHigh < 1.0 || this.m_dHigh > num;
				if (flag5)
				{
					this.m_strErrorInfo = "角钢高度有误";
					return false;
				}
				bool flag6 = this.m_dThick <= 0.0 || this.m_dThick > num || this.m_dThick >= this.m_dWide || this.m_dThick >= this.m_dHigh;
				if (flag6)
				{
					this.m_strErrorInfo = "角钢厚度有误";
					return false;
				}
				break;
			}
			case 'C':
			case 'H':
			{
				bool flag7 = this.m_dWide < 1.0 || this.m_dWide > num;
				if (flag7)
				{
					this.m_strErrorInfo = "宽度有误";
					return false;
				}
				bool flag8 = this.m_dHigh < 1.0 || this.m_dHigh > num;
				if (flag8)
				{
					this.m_strErrorInfo = "高度有误";
					return false;
				}
				bool flag9 = this.m_dThick <= 0.0 || this.m_dThick > num || this.m_dThick * 2.0 >= this.m_dWide || this.m_dThick * 2.0 >= this.m_dHigh;
				if (flag9)
				{
					this.m_strErrorInfo = "厚度有误";
					return false;
				}
				break;
			}
			case 'D':
			case 'G':
			{
				bool flag10 = this.m_dWide < 1.0 || this.m_dWide > num;
				if (flag10)
				{
					this.m_strErrorInfo = "宽度有误";
					return false;
				}
				bool flag11 = this.m_dHigh < 1.0 || this.m_dHigh > num;
				if (flag11)
				{
					this.m_strErrorInfo = "高度有误";
					return false;
				}
				bool flag12 = this.m_dThick <= 0.0 || this.m_dThick > num;
				if (flag12)
				{
					this.m_strErrorInfo = "厚度有误";
					return false;
				}
				bool flag13 = this.m_dThickMid <= 0.0 || this.m_dThickMid > num;
				if (flag13)
				{
					this.m_strErrorInfo = "中间厚度有误";
					return false;
				}
				break;
			}
			case 'E':
			case 'F':
			{
				bool flag14 = this.m_dWide < 1.0 || this.m_dWide > num;
				if (flag14)
				{
					this.m_strErrorInfo = "宽度有误";
					return false;
				}
				bool flag15 = this.m_dHigh < 1.0 || this.m_dHigh > num;
				if (flag15)
				{
					this.m_strErrorInfo = "高度有误";
					return false;
				}
				break;
			}
			}
			return true;
		}

		public bool IsSame(HSMatInfo cur)
		{
			bool flag = this.m_strName != cur.m_strName || this.m_strCode != cur.m_strCode || this.m_strMatLibName != cur.m_strMatLibName || this.m_strMatLibCode != cur.m_strMatLibCode || !this.m_dWide.Equals(cur.m_dWide) || !this.m_dHigh.Equals(cur.m_dHigh) || !this.m_dThick.Equals(cur.m_dThick) || !this.m_dThickMid.Equals(cur.m_dThickMid);
			return !flag;
		}

		public void Init()
		{
			this.m_strErrorInfo = "";
			this.m_strName = "角钢";
			this.m_strCode = "B";
			this.m_strMatLibName = "";
			this.m_strMatLibCode = "";
			this.m_dWide = 50.0;
			this.m_dHigh = 50.0;
			this.m_dThick = 10.0;
			this.m_dThickMid = 10.0;
			this.m_kSecType = HSMatInfo.MatSecType.角钢;
			this.m_lstTypeInfo = new List<string>();
			this.m_lstTypeInfo.Add("圆钢");
			this.m_lstTypeInfo.Add("角钢");
			this.m_lstTypeInfo.Add("槽钢");
			this.m_lstTypeInfo.Add("工字钢");
			this.m_lstTypeInfo.Add("扁钢");
			this.m_lstTypeInfo.Add("方钢");
			this.m_lstTypeInfo.Add("H钢");
			this.m_lstTypeInfo.Add("C钢");
		}

		public void SetTypeCode(string strCode)
		{
			this.m_strCode = strCode;
			int num = (int)(this.m_strCode[0] - 'A');
			this.m_kSecType = HSMatInfo.MatSecType.圆钢 + num;
			this.SetTypeCode(this.m_kSecType);
		}

		public void SetTypeCode(HSMatInfo.MatSecType kType)
		{
			this.m_kSecType = kType;
			string strName = this.m_lstTypeInfo[(int)this.m_kSecType];
			int num = 65;
			num = (int)(num + this.m_kSecType);
			this.m_strCode = Convert.ToChar(num).ToString();
			this.m_strName = strName;
		}

		public HSMatInfo.MatSecType 截面类型
		{
			get
			{
				return this.m_kSecType;
			}
			set
			{
				this.m_kSecType = value;
				this.SetTypeCode(this.m_kSecType);
			}
		}

		public double b宽
		{
			get
			{
				return this.m_dWide;
			}
			set
			{
				this.m_dWide = value;
			}
		}

		public double h高
		{
			get
			{
				return this.m_dHigh;
			}
			set
			{
				this.m_dHigh = value;
			}
		}

		public double t厚
		{
			get
			{
				return this.m_dThick;
			}
			set
			{
				this.m_dThick = value;
			}
		}

		public override string ToString()
		{
			return this.m_strName + "(" + this.GetSizeInfo() + ")";
		}

		public string GetSizeInfo()
		{
			string result;
			switch (this.m_strCode[0])
			{
			case 'A':
				result = "D" + this.m_dWide.ToString();
				break;
			case 'B':
				result = string.Concat(new string[]
				{
					this.m_dWide.ToString(),
					"x",
					this.m_dHigh.ToString(),
					"x",
					this.m_dThick.ToString()
				});
				break;
			case 'C':
				result = string.Concat(new string[]
				{
					this.m_dWide.ToString(),
					"x",
					this.m_dHigh.ToString(),
					"x",
					this.m_dThick.ToString()
				});
				break;
			case 'D':
				result = string.Concat(new string[]
				{
					this.m_dWide.ToString(),
					"x",
					this.m_dHigh.ToString(),
					"x",
					this.m_dThick.ToString()
				});
				break;
			case 'E':
				result = this.m_dWide.ToString() + "x" + this.m_dHigh.ToString();
				break;
			case 'F':
				result = this.m_dWide.ToString() + "x" + this.m_dHigh.ToString();
				break;
			case 'G':
				result = string.Concat(new string[]
				{
					this.m_dWide.ToString(),
					"x",
					this.m_dHigh.ToString(),
					"x",
					this.m_dThick.ToString()
				});
				break;
			case 'H':
				result = string.Concat(new string[]
				{
					this.m_dWide.ToString(),
					"x",
					this.m_dHigh.ToString(),
					"x",
					this.m_dThick.ToString()
				});
				break;
			default:
				result = string.Concat(new string[]
				{
					this.m_dWide.ToString(),
					"x",
					this.m_dHigh.ToString(),
					"x",
					this.m_dThick.ToString()
				});
				break;
			}
			return result;
		}

		public string m_strName;

		public string m_strCode;

		public string m_strMatLibName;

		public string m_strMatLibCode;

		public double m_dWide;

		public double m_dHigh;

		public double m_dThick;

		public double m_dThickMid;

		public string m_strErrorInfo;

		public HSMatInfo.MatSecType m_kSecType;

		private List<string> m_lstTypeInfo;

		public enum MatSecType
		{
			圆钢,
			角钢,
			槽钢,
			工字钢,
			扁钢,
			方钢,
			H钢,
			C钢
		}
	}
}
